/****************************************************************************
	This file is part of Basqet.

	Basqet is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Basqet is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
    along with Basqet.  If not, see <http://www.gnu.org/licenses/>.

****************************************************************************/

#ifndef NOTEDATA_H
#define NOTEDATA_H

#include <QObject>
#include <QSharedData>

#include <QSize>
#include <QPoint>
#include <QDomElement>
#include <QPointer>
#include <QString>
#include <QMap>
#include <QVariant>
#include <QStringList>

class BasketDescriptor;
class BasketContent;

class NoteData;
// typedef QExplicitlySharedDataPointer<NoteData> PNoteData;

class NoteData : public QObject, public QSharedData
{
	Q_OBJECT

	public:
		NoteData(BasketDescriptor* container, BasketContent* pContent);
		virtual void setup(QDomElement tag);
		virtual void copyFrom(const NoteData* other);

		QSize  getSize() const;
		QPoint getPosition() const;

		virtual bool removeNote();

		QString getNoteID();

		QStringList getTagList() const;
		void		setTagList(QStringList tags);

		QString		getTagBySameFamily(QString tagFamily);

		void		setTagValue(QString tag);
		void		clearTagValue(QString tag);
		bool		hasTag(QString tag);
		void		replaceTag(QString oldTag, QString newTag);


		BasketContent* getBasketContent() const;
		BasketDescriptor* getBasketDescriptor() const;

		virtual void getContents(QMap<QString, QVariant>& contents);
		virtual void setContents(const QMap<QString, QVariant>& contents);


	public slots:
		void setGeometry(QPoint pos, QSize size = QSize() );
		virtual void save();

	signals:
		void geometryChanged(QPoint pos, QSize size);
		void removed();

		void tagSet(QString tag);
		void tagCleared(QString tag);
		void tagChanged(QString oldTag, QString newTag);

	protected:
		QDomElement	getObjectNode();

	private:
		void setupXML(QPoint place);
		void setNoteID(QString noteId);


	protected:
		QPointer<BasketDescriptor>	mBasket;
		QPointer<BasketContent>		mBasketContent;

	private:

		QDomElement					mXML;
		QDomElement					mNoteID;
		QDomElement					mTagList;
		QDomAttr					mWidth;
		QDomAttr					mHeight;
		QDomAttr					mPosX;
		QDomAttr					mPosY;


};

#endif // NOTEDATA_H
